import string
#将数字，英语单词以及其他字符串、满足前四种情况的个数设置为0
num_count = str_count = eng_count = big_eng_count = count = 0
guard_count = 2

# 字符的统计,判断密码长度及数字大小写字母和标点符号出现的次数
def keywards():
    if len(keyward) >= 8:
        global guard_count
        guard_count += 1
    else:
        print("密码小于8位数...")
    for i in keyward:
        if i >= '0' and i <= '9':
            global  num_count
            num_count += 1
        elif (i >= 'A' and i <= 'Z'):
            global  big_eng_count
            big_eng_count += 1
        elif (i >= 'a' and i <= 'z'):
            global eng_count
            eng_count += 1
        elif ((i >= '0' and i <= '9') and (i >= 'a' and i <= 'z') and (i >= 'A' and i <= 'Z')) == False:
            global str_count
            str_count += 1

#判断四个条件中满足几个，当满足三个及以上时安全系数加一
    global count
    if (num_count >= 1):
        count += 1
    if (eng_count >= 1):
        count += 1
    if (str_count >= 1):
        count += 1
    if (big_eng_count >= 1):
        count += 1
    if count >= 3:
        guard_count += 1
    else:
        print("密码中不包括数字，大小写字母中的三个及以上数目...")
    #print(f"安全系数为:{guard_count}")
    #print(f"数字的个数为：{num_count}\n大写字母的个数为:{big_eng_count}\n其他字符的个数为:{str_count}\n小写字母的个数为:{eng_count}")


#判断是否有出现连续三个及以上的字符
def str_lenth():
    flag = True
    k = 0
    l = 0
    if len(keyward) <= 2:
        return
    elif len(keyward) == 3:
        if keyward[0] == keyward[1] == keyward[2]:
            print("密码中含有三个或以上的重复字符段...")
            return
        else:
            global guard_count
            guard_count += 1
    elif len((keyward)) > 3:
        for i in keyward[:-3]:
            #print(i,end="--")
            for j in keyward[k:k+3]:
                #print(j,end="-----")
                if i == j:
                    l = l + 1
            k += 1
            if l >= 3:
                flag = False
            else:
                l = 0
        #print(l)
        if l < 3:
            guard_count += 1
        elif l > 3:
            print("密码中含有三个或以上的重复字符段...")


# 程序的入口，输入提示信息及打印出结果
keyward = input("请输入您的密码：")
print("--------------------------------")
keywards()
str_lenth()
print(f"安全系数为:{guard_count}")
if guard_count == 5:
    print("密码设置成功.....")
